import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:daf/global.dart';
import 'package:daf/toolkit/aes.dart';
import 'package:daf/toolkit/daxie.dart';
import 'package:daf/toolkit/qrcode.dart';
import 'package:daf/toolkit/ruler.dart';

class HomePage extends StatefulWidget {
  HomePage({Key key}) : super(key: key);
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  void initState() {
    SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        decoration: BoxDecoration(
          gradient: LinearGradient(
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
            colors: [
              Global.primaryColor,
              Global.primaryColor.withOpacity(.4),
            ],
          ),
        ),
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              SizedBox(height: MediaQuery.of(context).padding.top),
              Container(
                height: 100,
                decoration: BoxDecoration(
                    image: DecorationImage(
                        image: AssetImage('assets/images/5342.png'))),
                child: Center(
                  child: Text(
                    '   Enzyme工具盒子',
                    style: TextStyle(
                      fontSize: 24,
                      fontWeight: FontWeight.w500,
                      color: Colors.white,
                      fontFamily: 'title',
                    ),
                  ),
                ),
              ),
              SizedBox(height: 10),
              InkWell(
                onTap: () {
                  Navigator.push(context,
                      MaterialPageRoute(builder: (context) => QrCodePage()));
                },
                child: Container(
                  padding: EdgeInsets.all(10),
                  margin: EdgeInsets.fromLTRB(20, 3, 20, 3),
                  height: 150,
                  decoration: BoxDecoration(
                    border: Border.all(
                      color: Global.backgroundColor.withOpacity(.3),
                      width: .5,
                    ),
                    borderRadius: BorderRadius.circular(10),
                    gradient: LinearGradient(
                      begin: Alignment.topLeft,
                      end: Alignment.bottomRight,
                      colors: [
                        Color.fromARGB(255, 188, 147, 255),
                        Color.fromARGB(255, 85, 153, 255),
                        Color.fromARGB(255, 60, 210, 237),
                        Color.fromARGB(255, 93, 255, 217),
                      ],
                    ),
                  ),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Text(
                        '生成二维码',
                        style: TextStyle(
                          color: Global.backgroundColor,
                          fontFamily: 'title',
                          fontSize: 30,
                          fontWeight: FontWeight.w500,
                        ),
                      ),
                      Image.asset('assets/images/11.png'),
                    ],
                  ),
                ),
              ),
              SizedBox(height: 25),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Expanded(
                    child: InkWell(
                      onTap: () {
                        Navigator.push(
                            context,
                            MaterialPageRoute(
                                builder: (context) => NumberDaxiePage()));
                      },
                      child: Container(
                        padding: EdgeInsets.all(10),
                        margin: EdgeInsets.fromLTRB(20, 3, 20, 3),
                        height: 210,
                        decoration: BoxDecoration(
                          border: Border.all(
                            color: Global.backgroundColor.withOpacity(.3),
                            width: .5,
                          ),
                          borderRadius: BorderRadius.circular(
                            10,
                          ),
                          gradient: LinearGradient(
                            begin: Alignment.topLeft,
                            end: Alignment.bottomRight,
                            colors: [
                              Color.fromARGB(255, 255, 220, 247),
                              Color.fromARGB(255, 232, 173, 110),
                            ],
                          ),
                        ),
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset('assets/images/123r.png'),
                            Text(
                              '金额大写转换',
                              style: TextStyle(
                                color: Global.backgroundColor,
                                fontFamily: 'title',
                                fontSize: 20,
                                fontWeight: FontWeight.w500,
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                  ),
                  Expanded(
                    child: InkWell(
                      onTap: () {
                        Navigator.push(
                            context,
                            MaterialPageRoute(
                                builder: (context) => TextAESPage()));
                      },
                      child: Container(
                        padding: EdgeInsets.all(10),
                        margin: EdgeInsets.fromLTRB(20, 3, 20, 3),
                        height: 210,
                        decoration: BoxDecoration(
                          border: Border.all(
                            color: Global.backgroundColor.withOpacity(.3),
                            width: .5,
                          ),
                          borderRadius: BorderRadius.circular(10),
                          gradient: LinearGradient(
                            begin: Alignment.topLeft,
                            end: Alignment.bottomRight,
                            colors: [
                              Color.fromARGB(255, 136, 255, 189),
                              Color.fromARGB(255, 0, 215, 132),
                            ],
                          ),
                        ),
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset('assets/images/13.png'),
                            Text(
                              '文案加解密',
                              style: TextStyle(
                                fontFamily: 'title',
                                color: Global.backgroundColor,
                                fontSize: 20,
                                fontWeight: FontWeight.w500,
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              SizedBox(height: 25),
              InkWell(
                onTap: () {
                  Navigator.push(context,
                      MaterialPageRoute(builder: (context) => RulerPage()));
                },
                child: Container(
                  padding: EdgeInsets.all(10),
                  margin: EdgeInsets.fromLTRB(20, 3, 20, 3),
                  height: 150,
                  decoration: BoxDecoration(
                    border: Border.all(
                      color: Global.backgroundColor.withOpacity(.3),
                      width: .5,
                    ),
                    borderRadius: BorderRadius.circular(
                      10,
                    ),
                    gradient: LinearGradient(
                      begin: Alignment.topLeft,
                      end: Alignment.bottomRight,
                      colors: [
                        Color.fromARGB(255, 255, 241, 87),
                        Color.fromARGB(255, 255, 192, 56),
                      ],
                    ),
                  ),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Image.asset('assets/images/13124.png'),
                      Text(
                        '厘米尺',
                        style: TextStyle(
                          color: Global.backgroundColor,
                          fontSize: 40,
                          fontFamily: 'title',
                          fontWeight: FontWeight.w500,
                        ),
                      ),
                    ],
                  ),
                ),
              ),
              SizedBox(height: 35),
            ],
          ),
        ),
      ),
    );
  }
}
